<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<script type="text/javascript">
    $(document).ready(function() {
        // 'DataTablize' the tables
        $("table").dataTable({
            "bPaginate": true,
            "sPaginationType": "full_numbers",
            "bFilter": true,
            "bJQueryUI": true,
            "bAutoWidth": false,
            "aoColumns": [{"sType": "html"},
                {"sType": "html"},
                {"sType": "numeric" },
                {"sType": "numeric" },
                null, null, null,
                {"bSearchable": false},
                {"bSearchable": false},
                {"bSearchable": false}]
        });
    });
</script>
<div id="snpList" class="content list">
    <html:form action="searchSubmit">
        <div class="input">
            <dl>
                <dt>Search SNPs:</dt>
                <dd><html:text property="searchText" />&nbsp;<html:submit property="submitType" value="Search" /></dd>
            </dl>
            <html:hidden property="searchSelect" value="1" />
        </div>
    </html:form>
    <h2>SNP List</h2>
    <table cellpadding="0" cellspacing="0" border="0" class="display">
        <thead>
            <tr>
                <!-- GOTCHA: Manually adding 'ui-state-default' classes to match appearance.
                             NOTE: There were couple old forum threads that stated that dataTable cannot
                             handle multiple th's in a row. This table, with two th's in each column seems
                             to be working now. However, this might cause a problem in future changes. -->
                <td colspan="7" class="ui-state-default">&nbsp;</td>
                <th colspan="<bean:write name="snpListForm" property="cohortListSize"/>" class="ui-state-default">Genotyping Status</th>
            </tr>
            <tr>
                <th>RS number</th>
                <th>Gene</th>
                <th>Chromosome</th>
                <th>Position</th>
                <th>Major Allele</th>
                <th>Minor Allele</th>
                <th>Function</th>
                <logic:iterate id="cohort" name="snpListForm" property="cohortList">
                    <th><bean:write name="cohort" property="name"/></th>
                </logic:iterate>
            </tr>
        </thead>
        <tbody>
            <logic:iterate id="snpInfo" name="snpListForm" property="snpList">
                <tr>
                    <td>
                        <a href="<html:rewrite page="/snpSummary.do" />?rsNumber=<bean:write name="snpInfo" property="snp.rsNumber"/>">
                            <bean:write name="snpInfo" property="snp.rsNumber"/>
                        </a>
                    </td>
                    <td>
                        <a href="geneSummary.do?geneName=<bean:write name="snpInfo" property="snp.gene.name"/>">
                            <bean:write name="snpInfo" property="snp.gene.name"/>
                        </a>
                    </td>
                    <td><bean:write name="snpInfo" property="snp.chromosome"/></td>
                    <td><bean:write name="snpInfo" property="snp.position"/></td>
                    <td><bean:write name="snpInfo" property="snp.majorAllele"/></td>
                    <td><bean:write name="snpInfo" property="snp.minorAllele"/></td>
                    <td>
                        <logic:notEmpty name="snpInfo" property="snp.fxnClass">
                            <bean:write name="snpInfo" property="snp.fxnClass"/>
                        </logic:notEmpty>
                    </td>
                    <logic:iterate id="status" name="snpInfo" property="statusList">
                        <td>
                            <logic:notEmpty name="status">
                                <logic:equal name="status" property="valid" value="true">
                                    <div title="Passed" class="ui-icon passed ui-icon-check" />
                                </logic:equal>
                                <logic:notEqual name="status" property="valid" value="true">
                                    <div title="Failed" class="ui-icon failed ui-icon-closethick" />
                                </logic:notEqual>
                            </logic:notEmpty>
                            <logic:empty name="status">
                                <div title="Not Available" class="ui-icon na ui-icon-help" />
                            </logic:empty>
                        </td>
                    </logic:iterate>
                </tr>
            </logic:iterate>
        </tbody>
    </table>
</div>